using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;
using Utility;

namespace BUS
{
    public class DoanhNghiep_BUS
    {
        public static void Insert(DoanhNghiep_DTO doanhNghiep)
        {
            DoanhNghiep_DAL doanhNghiepDAL = new DoanhNghiep_DAL();
            doanhNghiepDAL.Insert(doanhNghiep);
        }
        public static void Update(DoanhNghiep_DTO doanhNghiep)
        {
            DoanhNghiep_DAL doanhNghiepDAL = new DoanhNghiep_DAL();
            doanhNghiepDAL.Update(doanhNghiep);
        }
        public static void Delete(int iD)
        {
            DoanhNghiep_DAL doanhNghiepDAL = new DoanhNghiep_DAL();
            doanhNghiepDAL.Delete(iD);
        }
        public static tbDoanhNghiepCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            DoanhNghiep_DAL doanhNghiepDAL = new DoanhNghiep_DAL();
            return doanhNghiepDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDoanhNghiepCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            DoanhNghiep_DAL doanhNghiepDAL = new DoanhNghiep_DAL();
            return doanhNghiepDAL.Get(cri.Criter, 0, 0, tbDoanhNghiepColumns.MaDN.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static DoanhNghiep_DTO GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbDoanhNghiepColumns.MaDN.ToString(), Condition.EQUAL, iD);
            DoanhNghiep_DAL doanhNghiepDAL = new DoanhNghiep_DAL();
            tbDoanhNghiepCollection doanhNghiepCollection = doanhNghiepDAL.Get(cri.Criter,
                0, 0, tbDoanhNghiepColumns.MaDN.ToString(), OrderDirection.ASC.ToString(), out total);
            if (doanhNghiepCollection.Count > 0)
                return doanhNghiepCollection[0];
            return null;
        }
        public static DoanhNghiep_DTO GetByEMAIL(string email)
        {
            int total = 0;

            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbDoanhNghiepColumns.Email, Condition.EQUAL, email);
            DoanhNghiep_DAL doanhNghiepDAL = new DoanhNghiep_DAL();
            tbDoanhNghiepCollection doanhNghiepCollection = doanhNghiepDAL.Get(cri.Criter,
                0, 0, tbDoanhNghiepColumns.MaDN.ToString(), OrderDirection.ASC.ToString(), out total);
            if (doanhNghiepCollection.Count > 0)
                return doanhNghiepCollection[0];
            return null;
        }
        public static tbDoanhNghiepCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DoanhNghiep_DAL doanhNghiepDAL = new DoanhNghiep_DAL();
            return doanhNghiepDAL.Get(cri.Criter, 1, number,
                tbDoanhNghiepColumns.MaDN.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDoanhNghiepCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DoanhNghiep_DAL doanhNghiepDAL = new DoanhNghiep_DAL();
            return doanhNghiepDAL.Get(cri.Criter, 1, number,
                tbDoanhNghiepColumns.MaDN.ToString(), OrderDirection.DESC.ToString(), out total);
        }

    }
}
